home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / eckelt01.zip / ALLEGE.H next >
C/C++ Source or Header  |  1994-10-31  |  535b  |  29 lines

  1. //: ALLEGE.H -- Error checking
  2. #ifndef ALLEGE_H_
  3. #define ALLEGE_H_
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <assert.h>
  7.  
  8. inline void
  9. allege_error(int val, const char * msg){
  10.   if(!val) {
  11.     fprintf(stderr, "error: %s\n", msg);
  12. #ifdef NDEBUG
  13.     exit(1);
  14. #endif
  15.   }
  16. }
  17.  
  18. #define allege(expr, msg) \
  19. {  allege_error((expr) ? 1 : 0, msg); \
  20.   assert(expr); }
  21.  
  22. #define allegemem(expr) \
  23.   allege(expr, "out of memory")
  24.  
  25. #define allegefile(expr) \
  26.   allege(expr, "could not open file")
  27.  
  28. #endif // ALLEGE_H_
  29.